/**
 * 
 */
package com.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 4833 robben
 * 2014-5-10 下午3:04:06
 */
public abstract class User extends Target {
	private String password;
	private UserGroup userGroup;
	private List<Right> rights;
	
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public UserGroup getUserGroup() {
		return userGroup;
	}
	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}
	public List<Right> getRights() {
		return rights;
	}
	public void setRights(List<Right> rights) {
		this.rights = rights;
	}
	
	public String doAddOperation(Operation operation, Target target) {
		if(operation.checkRight(this.getUserGroup().getCode(), target.getType())) {
			return operation.add(target);
		} else {
			return null;
		}
	}
	
	public boolean doRemoveOperation(Operation operation, Target target) {
		if(operation.checkRight(this.getUserGroup().getCode(), target.getType())) {
			return operation.remove(target);
		} else {
			return false;
		}
	}
	
	public boolean doModifyOperation(Operation operation, Target target) {
		if(operation.checkRight(this.getUserGroup().getCode(), target.getType())) {
			return operation.modify(target);
		} else {
			return false;
		}
	}
	
}
